﻿#include "codemanager.h"

#include <QDebug>

CodeManager::CodeManager()
{

}

void CodeManager::commit(Memento *memento)
{
    m_mementoVector.append(memento);
}

Memento *CodeManager::checkout(int index)
{
    m_mementoVector.erase(m_mementoVector.begin() + m_mementoVector.size() - index, m_mementoVector.end());
    return m_mementoVector[m_mementoVector.size() - 1];
}

void CodeManager::codeLog()
{
    for (int i = 0; i < m_mementoVector.size(); i++) {
        qDebug() << m_mementoVector[i]->version() << ": " << m_mementoVector[i]->date() << " " << m_mementoVector[i]->label();
    }
}
